import javax.xml.soap.Node;
import java.util.LinkedList;
import java.util.Stack;

public class Text {
    public static void main(String[] args) {
        LinkedList<Integer> stack = new LinkedList<>();
        stack.push(1);
        stack.push(2);
        stack.push(3);
        stack.push(4);
        System.out.println(stack.peek());
        System.out.println(stack.pop());
        System.out.println(stack.pop());
        System.out.println(stack.pop());
        System.out.println(stack.pop());
    }
    public static void main3(String[] args) {
        Stack<Integer> stack = new Stack<>();
        int a = 800;
        stack.push(a);
        System.out.println(stack.peek() == a);
    }
//    //递归打印链表
    //得在链表内部写这个才行
//    public static void playList(Node pHead){
//        if(pHead == null){
//            return ;
//        }
//
//        if(pHead.next == null){
//            System.out.println(pHead.val);
//            return ;
//        }
//
//        playList(pHead.next);
//        System.out.println(pHead.val);
//    }

//    //使用栈来逆着打印单向链表
//    public static void playList1(){
//        Stack<Node> stack = new Stack<>();
//        Node cur = head;
//        while(cur != null){
//            stack.push(cur);
//            cur = cur.next;
//        }
//        while(!stack.isEmpty()){
//            Node temp = stack.pop();
//            System.out.print(temp.val+" ");
//        }
//        System.out.println();
//    }
    public static void main2(String[] args) {
        LinkedList<Integer> linkedList = new LinkedList<>();
        linkedList.add(1);
        linkedList.add(3);
        linkedList.add(5);
        linkedList.add(7);
        linkedList.add(11);
        System.out.println(linkedList);
    }
    public static void main1(String[] args) {
        Stack<Integer> stack = new Stack<>();
        stack.push(0);
        stack.push(1);
        stack.push(2);
        stack.push(3);
        stack.push(4);
        stack.push(5);
        System.out.println(stack.size());
        System.out.print(stack.pop()+" ");
        System.out.print(stack.pop()+" ");
        System.out.print(stack.pop()+" ");
        System.out.print(stack.peek()+" ");//返回栈顶元素，但该元素依旧留在栈顶
        System.out.print(stack.peek()+" ");
        System.out.print(stack.pop()+" ");//返回栈顶元素，并将该元素出栈
        System.out.print(stack.pop()+" ");
        System.out.println(stack.pop()+" ");
        System.out.println(stack.empty());
    }
}
